package main

import (
	"flag"
	"fmt"
	"log"
	"net"

	//lua_seri "github.com/xingshuo/lua-serialize"
	logic "go-node/logic"
)

var (
	addr string
)

func main() {
	flag.StringVar(&addr, "addr", ":5051", "listen addr")
	flag.Parse()
	lis, err := net.Listen("tcp", addr)
	if err != nil {
		panic(fmt.Sprintf("socket listen err:%v", err))
	}
	log.Printf("listen %s ok!\n", addr)
	for {
		conn, err := lis.Accept()
		if err != nil {
			panic(fmt.Sprintf("socket accpet err:%v", err))
		}
		log.Printf(" %v is conn!\n", conn)
		go logic.HandleConn(conn)

	}

}
